package com.zhl.random;

import java.util.Random;
import java.util.Scanner;

public class RandomTest2 {
    public static void main(String[] args) {
        //猜数字 1-100
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        int RightNum = r.nextInt(100)+1;
        do {
            System.out.print("请输入你猜测的数字：");
            int guess = sc.nextInt();

            if (guess == RightNum){
                System.out.println("恭喜你猜对了！");
                break;  //退出循环,结束游戏
            }else if(guess > RightNum){
                System.out.println("猜大了！");
            }
            else{
                System.out.println("猜小了！");
            }

        }while(true);








    }
}
